package x.java.tea;

import java.util.Collection;
import java.util.Iterator;

public class TemplateIteratorInjector extends IteratorInjector {

	protected String template;
		
	public TemplateIteratorInjector(String template) {
		this.template = template;
	}

	public TemplateIteratorInjector(Collection<? extends Object> c, String template) {
		super(c);
		this.template = template;
	}

	public TemplateIteratorInjector(Iterator<Object> it, String template) {
		super(it);
		this.template = template;
	}

	public TemplateIteratorInjector(Object[] a, String template) {
		super(a);
		this.template = template;
	}

	@Override
	protected void setBuf(Object obj) {
		Object args = getElements(obj);
		TemplateObjectInjector inj = new TemplateObjectInjector(args,template);
		setBuf(inj);
	}

	/**
	 * Transform obj if appropriate. Default implementation returns obj as is.
	 * 
	 * @param obj
	 * @return
	 */
	protected Object getElements(Object obj) {
		return obj;
	}
}
